<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <title>编辑作业</title>
    <link rel="stylesheet" href="https://www.layuicdn.com/layui-v2.6.8/css/layui.css">
    <script src="https://www.layuicdn.com/layui-v2.6.8/layui.js"></script>
    <style>
        .main-container {
            padding: 20px;
            max-width: 800px;
            margin: 0 auto;
        }
        .layui-form-item {
            margin-bottom: 25px;
        }
        .form-buttons {
            margin-top: 30px;
        }
    </style>
</head>
<body>
    <div class="main-container">
        <div class="layui-card">
            <div class="layui-card-header">
                <h2>编辑作业</h2>
            </div>
            <div class="layui-card-body">
                <form class="layui-form" action="${pageContext.request.contextPath}/teacher/assignment/update" method="post">
                    <input type="hidden" name="aid" value="${assignment.aid}">
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label">作业标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" required lay-verify="required" 
                                   placeholder="请输入作业标题" class="layui-input" value="${assignment.title}">
                        </div>
                    </div>
                    
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">作业内容</label>
                        <div class="layui-input-block">
                            <textarea name="content" placeholder="请输入作业内容" class="layui-textarea" 
                                      required lay-verify="required" rows="10">${assignment.content}</textarea>
                        </div>
                    </div>
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label">截止时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="deadline" id="deadline" lay-verify="required" 
                                   placeholder="yyyy-MM-dd HH:mm:ss" class="layui-input" 
                                   value="<fmt:formatDate value="${assignment.deadline}" pattern="yyyy-MM-dd HH:mm:ss"/>">
                        </div>
                    </div>
                    
                    <div class="layui-form-item form-buttons">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="editForm">
                                <i class="layui-icon layui-icon-ok"></i> 保存修改
                            </button>
                            <button type="button" class="layui-btn layui-btn-primary" onclick="history.back()">
                                <i class="layui-icon layui-icon-return"></i> 返回
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script>
        layui.use(['form', 'laydate', 'layer'], function(){
            var form = layui.form;
            var laydate = layui.laydate;
            var layer = layui.layer;
            
            // 初始化日期时间选择器
            laydate.render({
                elem: '#deadline',
                type: 'datetime',
                format: 'yyyy-MM-dd HH:mm:ss',
                trigger: 'click'
            });
            
            form.on('submit(editForm)', function(data){
                // 表单提交前确认
                layer.confirm('确定要保存修改吗？', {icon: 3, title:'提示'}, function(index){
                    data.form.submit();
                    layer.close(index);
                });
                return false;
            });
        });
    </script>
</body>
</html> 